import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

Blockly.Blocks.function_ascii = {
  init: function () {
    this.appendValueInput('parsing_state')
      .setCheck(['String', 'Number'])
      .setAlign(Blockly.ALIGN_RIGHT)
      .appendField('ascii(')
    this.appendDummyInput().appendField(')')
    this.setInputsInline(true)
    this.setOutput(true, 'String')
    this.setColour(230)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

Blockly.Python.function_ascii = function (block) {
  const valueParsingState = Blockly.Python.valueToCode(
    block,
    'parsing_state',
    Blockly.Python.ORDER_NONE
  )
  const code = 'ascii(' + valueParsingState + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

export default Blockly
